using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.Skins;
using DevExpress.LookAndFeel;
using DevExpress.UserSkins;
using DevExpress.XtraEditors;
using QLNhaSach.Report;
using System.Diagnostics;
using System.IO;
using System.Reflection;

namespace WindowsApplication1
{
    public partial class Form1 : XtraForm
    {
        private QLNhaSach.Modules.TraCuuSach traCuuSach;
        private QLNhaSach.Modules.LapBaoCaoTon baoCaoTon;
        private QLNhaSach.Modules.LapBaoCaoCongNo baoCaoCongNo;
        private QLNhaSach.Modules.ThemKhachHang themKhachHang;
        private QLNhaSach.Modules.ThemSach themSach;
        private QLNhaSach.Modules.LapHoaDon lapHoaDon;
        private QLNhaSach.Modules.ThongTin.ThongTinSach thongTinSach;
        private QLNhaSach.Modules.ThongTin.DanhSachHoaDon danhSachHoaDon;
        private QLNhaSach.Modules.ThongTin.DanhSachKhachHang danhSachKhachHang;
        private QLNhaSach.Modules.ThongTin.DanhSachPhieuThu danhSachPhieuThu;
        private QLNhaSach.Modules.ThongTin.DanhSachBaoCaoTon danhSachBaoCaoTon;
        private QLNhaSach.Modules.ThongTin.DanhSachBaoCaoCongNo danhSachBaoCaoCongNo;
        private QLNhaSach.Modules.ThongTin.ChiTietHoaDon chiTietHoaDon;
        private QLNhaSach.Modules.TheLoaiTacGia theLoaiTacGia;
        private int userid;

        public int Userid
        {
            get { return userid; }
            set { userid = value; }
        }

        public Form1()
        {
            InitializeComponent();

            // 
            // Tra cứu sách
            // 
            this.traCuuSach = new QLNhaSach.Modules.TraCuuSach();
            this.traCuuSach.Dock = System.Windows.Forms.DockStyle.Fill;
            this.traCuuSach.Location = new System.Drawing.Point(0, 0);
            this.traCuuSach.Name = "traCuuSach";
            this.traCuuSach.Size = new System.Drawing.Size(768, 516);
            this.traCuuSach.TabIndex = 0;


            // 
            // Báo cáo tồn
            // 
            this.baoCaoTon = new QLNhaSach.Modules.LapBaoCaoTon();
            this.baoCaoTon.Dock = System.Windows.Forms.DockStyle.Fill;


            this.baoCaoTon.Location = new System.Drawing.Point(0, 0);
            this.baoCaoTon.Name = "baoCaoTon";
            this.baoCaoTon.Size = new System.Drawing.Size(768, 516);
            this.baoCaoTon.TabIndex = 1;

            // 
            // Báo cáo công nợ
            // 
            this.baoCaoCongNo = new QLNhaSach.Modules.LapBaoCaoCongNo();
            this.baoCaoCongNo.Dock = System.Windows.Forms.DockStyle.Fill;
            this.baoCaoCongNo.Location = new System.Drawing.Point(0, 0);
            this.baoCaoCongNo.Name = "baoCaoTon";
            this.baoCaoCongNo.Size = new System.Drawing.Size(768, 516);
            this.baoCaoCongNo.TabIndex = 2;

            // 
            // Lập hóa đơn bán sách 
            // 
            this.lapHoaDon = new QLNhaSach.Modules.LapHoaDon();
            this.lapHoaDon.Dock = System.Windows.Forms.DockStyle.Fill;
            this.traCuuSach.Location = new System.Drawing.Point(0, 0);
            this.traCuuSach.Name = "lapHoaDon";
            this.traCuuSach.Size = new System.Drawing.Size(768, 516);
            this.traCuuSach.TabIndex = 0;

            // 
            // Thêm khách hàng
            // 
            this.themKhachHang = new QLNhaSach.Modules.ThemKhachHang();
            this.themKhachHang.Dock = System.Windows.Forms.DockStyle.Fill;
            this.themKhachHang.Location = new System.Drawing.Point(0, 0);
            this.themKhachHang.Name = "themKhachHang";
            this.themKhachHang.Size = new System.Drawing.Size(768, 516);
            this.themKhachHang.TabIndex = 3;

            // 
            // Thêm sách
            // 
            this.themSach = new QLNhaSach.Modules.ThemSach();
            this.themSach.Dock = System.Windows.Forms.DockStyle.Fill;
            this.themSach.Location = new System.Drawing.Point(0, 0);
            this.themSach.Name = "themSach";
            this.themSach.Size = new System.Drawing.Size(768, 516);
            this.themSach.TabIndex = 4;

            // 
            // Thông tin sách
            // 
            this.thongTinSach = new QLNhaSach.Modules.ThongTin.ThongTinSach();
            this.thongTinSach.Dock = System.Windows.Forms.DockStyle.Fill;
            this.thongTinSach.Location = new System.Drawing.Point(0, 0);
            this.thongTinSach.Name = "thongTinSach";
            this.thongTinSach.Size = new System.Drawing.Size(768, 516);
            this.thongTinSach.TabIndex = 5;
            // 
            // Danh sách hoá đơn
            // 
            this.danhSachHoaDon = new QLNhaSach.Modules.ThongTin.DanhSachHoaDon();
            this.danhSachHoaDon.Dock = System.Windows.Forms.DockStyle.Fill;
            this.danhSachHoaDon.Location = new System.Drawing.Point(0, 0);
            this.danhSachHoaDon.Name = "danhSachHoaDon";
            this.danhSachHoaDon.Size = new System.Drawing.Size(768, 516);
            this.danhSachHoaDon.TabIndex = 6;
            // 
            // Danh sách khách hàng
            // 
            this.danhSachKhachHang = new QLNhaSach.Modules.ThongTin.DanhSachKhachHang();
            this.danhSachKhachHang.Dock = System.Windows.Forms.DockStyle.Fill;
            this.danhSachKhachHang.Location = new System.Drawing.Point(0, 0);
            this.danhSachKhachHang.Name = "danhSachKhachHang";
            this.danhSachKhachHang.Size = new System.Drawing.Size(768, 516);
            this.danhSachKhachHang.TabIndex = 7;
            // 
            // Danh sách phiếu thu
            // 
            this.danhSachPhieuThu = new QLNhaSach.Modules.ThongTin.DanhSachPhieuThu();
            this.danhSachPhieuThu.Dock = System.Windows.Forms.DockStyle.Fill;
            this.danhSachPhieuThu.Location = new System.Drawing.Point(0, 0);
            this.danhSachPhieuThu.Name = "danhSachPhieuThu";
            this.danhSachPhieuThu.Size = new System.Drawing.Size(768, 516);
            this.danhSachPhieuThu.TabIndex = 8;
            // 
            // Danh sách báo cáo công nợ
            // 
            this.danhSachBaoCaoCongNo = new QLNhaSach.Modules.ThongTin.DanhSachBaoCaoCongNo();
            this.danhSachBaoCaoCongNo.Dock = System.Windows.Forms.DockStyle.Fill;
            this.danhSachBaoCaoCongNo.Location = new System.Drawing.Point(0, 0);
            this.danhSachBaoCaoCongNo.Name = "danhSachBaoCaoCongNo";
            this.danhSachBaoCaoCongNo.Size = new System.Drawing.Size(768, 516);
            this.danhSachBaoCaoCongNo.TabIndex = 9;

            // 
            // Danh sách báo cáo tồn
            // 
            this.danhSachBaoCaoTon = new QLNhaSach.Modules.ThongTin.DanhSachBaoCaoTon();
            this.danhSachBaoCaoTon.Dock = System.Windows.Forms.DockStyle.Fill;
            this.danhSachBaoCaoTon.Location = new System.Drawing.Point(0, 0);
            this.danhSachBaoCaoTon.Name = "danhSachBaoCaoTon";
            this.danhSachBaoCaoTon.Size = new System.Drawing.Size(768, 516);
            this.danhSachBaoCaoTon.TabIndex = 10;
            // 
            // Chi tiết hoá đơn
            // 
            this.chiTietHoaDon = new QLNhaSach.Modules.ThongTin.ChiTietHoaDon();
            this.chiTietHoaDon.Dock = System.Windows.Forms.DockStyle.Fill;
            this.chiTietHoaDon.Location = new System.Drawing.Point(0, 0);
            this.chiTietHoaDon.Name = "chiTietHoaDon";
            this.chiTietHoaDon.Size = new System.Drawing.Size(768, 516);
            this.chiTietHoaDon.TabIndex = 10;
            // 
            // Tác giả - Thể loại
            // 
            this.theLoaiTacGia = new QLNhaSach.Modules.TheLoaiTacGia();
            this.theLoaiTacGia.Dock = System.Windows.Forms.DockStyle.Fill;
            this.theLoaiTacGia.Location = new System.Drawing.Point(0, 0);
            this.theLoaiTacGia.Name = "theLoaiTacGia";
            this.theLoaiTacGia.Size = new System.Drawing.Size(768, 516);
            this.theLoaiTacGia.TabIndex = 10;
        }

        private void inboxItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.lapPhieuNhapSach1);
        }

        private void draftsItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.traCuuSach);
        }

        private void navBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.baoCaoTon);
        }

        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.baoCaoCongNo);
        }

        private void outboxItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.lapHoaDon);

        }

        private void barStaticItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Environment.Exit(1);
        }

        private void navBarItem4_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.themKhachHang);
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            Environment.Exit(1);
        }

        private void navBarItem9_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.themSach);
        }

        private void calendarItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.thongTinSach);
        }

        private void tasksItem_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.danhSachHoaDon);
        }

        private void navBarItem5_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.danhSachPhieuThu);
        }

        private void navBarItem6_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.danhSachKhachHang);
        }

        private void navBarItem7_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.danhSachBaoCaoCongNo);
        }

        private void navBarItem8_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.danhSachBaoCaoTon);
        }
        public void ucChiTietHoaDon(){
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.chiTietHoaDon);
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            if (userid == 2)
            {
                navBarGroup1.Visible = false;
            }
        }

        private void navBarItem10_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            this.splitContainerControl.Panel2.Controls.Clear();
            this.splitContainerControl.Panel2.Controls.Add(this.theLoaiTacGia);
        }

        private void barButtonItem4_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            SachForm frm = new SachForm();
            frm.Show();
        }

        private void barButtonItem6_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            KhachHangForm frm = new KhachHangForm();
            frm.Show();
        }

        private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            HoaDonForm frm = new HoaDonForm();
            frm.Show();
        }

        private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            BaoCaoTonForm frm = new BaoCaoTonForm();
            frm.Show();
        }

        private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            BaoCaoCongNoForm frm = new BaoCaoCongNoForm();
            frm.Show();
        }

        private void barButtonItem3_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            string cwd = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string projectName = "QLNhaSach";
            string solutionPath = cwd.Replace("\\bin\\Release\\" + projectName + ".exe", "");
            Process.Start(solutionPath + "\\CHM\\Tutorial_QLNS.chm");
        }
    }
}
